<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
		"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:rich="http://richfaces.org/rich">
<f:view>
	<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
	                template="../../template/defaultMenuTemplate.xhtml">
		<ui:define name="content">
			<h:panelGrid columns="2" width="100%" cellpadding="0" cellspacing="0" columnClasses="panelGrid">
				<h:form id="registerForm"  style="text-space-collapse: preserve">
					<rich:panel style=" padding: 1px;width:50%;" bodyClass="inpanelBody">
						<f:facet name="header">
							<h:outputText value="#{BundleLabels.register_user}"/>
						</f:facet>
						<h:outputText value="#{BundleLabels.user_name}"/>
						<h:message showDetail="false" for="username" errorStyle="color: red" infoStyle="color: green"/>
						<h:inputText id="username" value="#{userController.userTO.userName}"
									 required="true" validatorMessage="#{BundleLabels.validateInputEmpty}">
							<!--<f:ajax render="clientOnServerSide" execute="@this"/>-->
						</h:inputText>
						<br/>
						<h:outputText value="#{BundleLabels.name}"/>
						<h:message showDetail="false" for="name" errorStyle="color: red" infoStyle="color: green"/>
						<h:inputText id="name" value="#{userController.userTO.name}"
						             required="true" validatorMessage="#{BundleLabels.validateInputEmpty}">
							<!--<f:ajax render="clientOnServerSide" execute="@this"/>-->
						</h:inputText>
						<br/>
						<h:outputText value="#{BundleLabels.lastName}"/>
						<h:message for="lastname" errorStyle="color: red" infoStyle="color: green"/>
						<h:inputText id="lastname"
						             value="#{userController.userTO.lastName1}"
						             required="true" validatorMessage="#{BundleLabels.validateInputEmpty}">
							<!--<f:ajax render="clientOnServerSide" execute="@this"/>-->
						</h:inputText>
						<br/>
						<h:selectManyListbox disabled="false" value="#{userController.userTO.rolList}">
							<f:selectItems value="#{userController.allRolValues}" />
						</h:selectManyListbox>
						<br/>
						<h:outputText value="#{BundleLabels.documentId}"/>
						<h:message for="typeDocument" errorStyle="color: red" infoStyle="color: green"/>
						<h:message for="documentId" errorStyle="color: red" infoStyle="color: green"/>
						<h:selectOneMenu id="typeDocument" value="#{userController.userTO.typeDocument}"
						                 required="true">
							<f:selectItem itemValue="#{BundleLabels.NIE}" itemLabel="#{BundleLabels.NIE}"/>
							<f:selectItem itemValue="P" itemLabel="#{BundleLabels.PASPPORT}"/>
							<f:selectItem itemValue="#{BundleLabels.DNI}" itemLabel="#{BundleLabels.DNI}"/>
							<f:selectItem itemValue="#{BundleLabels.NIF}" itemLabel="#{BundleLabels.NIF}"/>
						</h:selectOneMenu>
						<h:inputText id="documentId"
						             value="#{userController.userTO.documentId}"
						             required="true" validatorMessage="#{BundleLabels.validateInputEmpty}">
							<!--<f:ajax render="clientOnServerSide" execute="@this"/>-->
						</h:inputText>
						<!--<f:ajax render="clientOnServerSide" execute="@this"/>-->

						<br/>
						<h:outputText value="#{BundleLabels.email}"/>
						<rich:message for="email" errorStyle="color: red" infoStyle="color: green"/>
						<h:inputText id="email"
						             value="#{userController.userTO.email}"
						             required="true" validatorMessage="#{BundleLabels.validateInputEmpty}">
							<!--<f:ajax render="clientOnServerSide" execute="@this"/>-->
							<!--<t:validateEmail message="#{BundleLabels.validateMailError}"/>-->
							<f:validateRegex
									pattern="^(([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+([;.](([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+)*$"/>
							<rich:validator/>
						</h:inputText>
						<br/>
						<h:outputText value="#{BundleLabels.password}"/>
						<h:message for="password" errorStyle="color: red" infoStyle="color: green"/>
						<h:inputSecret id="password" value="#{userController.userTO.security.password}"
						               required="true" validatorMessage="#{BundleLabels.validateInputEmpty}">
							<!--	<f:ajax render="clientOnServerSide" execute="@this"/>-->
						</h:inputSecret>
						<br/>
						<br/>
						<h:outputText value="#{BundleLabels.confirm_password}"/>
						<h:message for="passwordRepeat" errorStyle="color: red" infoStyle="color: green"/>
						<h:inputSecret id="passwordRepeat" value="#{userController.passworConfirm}"
						               required="true" validatorMessage="#{BundleLabels.validateInputEmpty}"/>
						<h:commandButton action="#{userController.saveUser}" value="#{BundleLabels.btn_register}"/>
					</rich:panel>
				</h:form>
				<h:form id="updateForm">
					<rich:panel style=" padding: 1px;width: 100%;" bodyClass="inpanelBody">
						<rich:dataTable width="100%" id="carList" rows="10" columnClasses="col"
						                value="#{userController.allUser}" var="user">
							<f:facet name="header">
								<rich:columnGroup>
									<h:column>
										<h:outputText styleClass="headerText" value="Nombre de usuario"/>
									</h:column>
									<h:column>
										<h:outputText styleClass="headerText" value="Nombre"/>
									</h:column>
									<h:column>
										<h:outputText styleClass="headerText" value="Apellido"/>
									</h:column>
									<h:column>
										<h:outputText styleClass="headerText" value="Email"/>
									</h:column>
									<h:column>
										<h:outputText styleClass="headerText" value="Id"/>
									</h:column>
                                    <h:column>
                                        <h:outputText styleClass="headerText" value="Roles Asignados"/>
                                    </h:column>
									<h:column>
										<h:outputText styleClass="headerText" value="Estatus"/>
									</h:column>
                                    <h:column/>
                                    <h:column/>
								</rich:columnGroup>
							</f:facet>
							<h:column>
								<h:outputText value="#{user.userName}"/>
							</h:column>
							<h:column>
								<h:outputText value="#{user.name}"/>
							</h:column>
							<h:column>
								<h:outputText value="#{user.lastName1}"/>
							</h:column>
							<h:column>
								<h:outputText value="#{user.email}"/>
							</h:column>
							<h:column>
								<h:outputText value="#{user.documentId}"/>
							</h:column>
                            <h:column>
                                <h:selectManyListbox disabled="true" value="#{user.rolList}">
                                    <f:selectItems value="#{user.rolList}" var="rol"
                                                   itemLabel="#{rol.name}" itemValue="#{rol.name}" />
                                </h:selectManyListbox>
                            </h:column>
							<h:column>
								<h:selectBooleanCheckbox disabled="true" value="#{user.isActive}"/>
							</h:column>
                            <h:column>
							<h:outputLink styleClass="ico ver-mas" title="#{BundleLabels.btn_update}"
							              value="#{facesContext.externalContext.requestContextPath}/modify.xhtml">
								<f:param name="userModify" value="#{user}"/>
                                <h:outputText value="#{BundleLabels.btn_update}"/>
							</h:outputLink>
                            </h:column>
                            <h:column>
							<h:commandButton action="#{userController.deleteUser(user.code)}"
							                 value="#{BundleLabels.btn_detele}">
							</h:commandButton>
                            </h:column>
						</rich:dataTable>
					</rich:panel>
				</h:form>
			</h:panelGrid>
		</ui:define>
	</ui:composition>
</f:view>
</html>
